/* 推荐 Api */
import { API, ERR_CODE } from 'api/config'
import axios from 'axios'
// import 'common/js/axios'
// import Vue from 'vue'

export const Banner = `${API}/banner` //  轮播图
export const Personalized = `${API}/personalized` //  推荐歌单

/* 获取轮播图 */
export function getBanner () {
  return axios.post(Banner, null, {
    withCredentials: false
  }).then(res => {
    if (res.code === ERR_CODE) {
      return Promise.resolve(res.banners)
    } else {
      return Promise.reject(res)
    }
  }).catch(err => {
    return Promise.reject(err)
  })
}

/* 获取轮播图 */
export function getRecommend () {
  return axios.post(Personalized, null, {
    withCredentials: false
  }).then(res => {
    if (res.code === ERR_CODE) {
      return Promise.resolve(res.result)
    } else {
      return Promise.reject(res)
    }
  }).catch(err => {
    return Promise.reject(err)
  })
}
